package com.liuyi.usercenterservice.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author 刘燚
 * @version v1.0.0
 * @Description TODO
 * @createDate：2024/6/14 00:10
 * @email liuyia2022@163.com
 */
@Configuration
@EnableOpenApi
@Profile({"dev"})
public class knife4jConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.liuyi.usercenterservice.controller")) // 自行修改！
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 项目基本信息配置
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("项目标题")
                .description("项目描述")
                .termsOfServiceUrl("http://www.example.com")
                //填写项目联系人信息（名称、网址、邮箱）
                .contact(new Contact("czk", "czk.com", "czk@163.com"))
                //填写项目版本号
                .version("1.0")
                .build();
    }
}
